﻿using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using OpenMms.Domain.BLL;
using OpenMms.Domain.Interface;
using OpenMms.Domain.Interface.User;
using OpenMms.Domain.Models;
using OpenMms.Factory;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Xunit;

namespace OpenMms.Test
{
    /// <summary>
    /// 测试基类
    /// </summary>
    public class TestBase
    {
        protected AutofacServiceProvider _autofacServiceProvider;
        /// <summary>
        /// 注入
        /// </summary>
        public TestBase()
        {
            var serviceCollection = GetServices();
            serviceCollection.AddMemoryCache();
            serviceCollection.AddOptions();
            //serviceCollection.AddScoped(typeof(IBLLConstruct<>), typeof(BLLConstruct<>));

            serviceCollection.AddDbContext<OpenMmsDBContext>(options =>
                options.UseSqlServer("Data Source=DESKTOP-D2CCMGU\\GUOWENHAO;Initial Catalog=OpenMmsDB;User=sa;Password=1234;Integrated Security=True"));
        

            var container = AutofacExt.InitAutofac(serviceCollection);
            _autofacServiceProvider = new AutofacServiceProvider(container);

        }
      
        /// <summary>
        /// 测试框架默认只注入了缓存Cache，配置Option；
        /// 如果在测试的过程中需要模拟登录用户，cookie等信息，需要重写该方法
        /// </summary>
        public virtual ServiceCollection GetServices()
        {
            return new ServiceCollection();
        }
    }
}
